package com.jyh.homework.homework3;

import java.util.ArrayList;
import java.util.Scanner;

public class MainAPP {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        list.add(new Student("it001", "黄渤", "男", 20, 1.72));
        list.add(new Student("it002", "孙红雷", "男", 22, 1.78));
        list.add(new Student("it003", "章子怡", "女", 18, 1.64));
        printAll(list);
        findMaxHeight(list);

    }

    public static void printAll(ArrayList<Student> stuList) {
        System.out.println("学号\t姓名\t性别\t年龄\t身高");
        for (Student student : stuList) {
            System.out.println(student.getId()+"\t"+student.getName()+"\t"+student.getSex()+"\t"+student.getAge()+"\t"+student.getTall());
        }
    }

    public static void findMaxHeight(ArrayList<Student> stuList){
        //假设集合里0号索引位置的元素的身高值是最高的
        Student tallMax=stuList.get(0);
        //遍历集合并输出
        for (int i = 0; i < stuList.size(); i++) {
            //判断tallMax得到的身高如果不是最高的就把最高的赋值给tallMax
            if (tallMax.getTall()<stuList.get(i).getTall()){
                tallMax=stuList.get(i);
            }
        }
        System.out.println(tallMax);
    }
}
